package com.order.application.service;

import com.order.application.dto.OrderDTO;
import com.order.domain.models.OrderEntity;
import com.order.domain.repository.IOrderRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import static com.order.application.service.converter.OrderEntityConverter.entity2OrderDTO;
import static com.order.application.service.converter.OrderEntityConverter.orderDTO2OrderEntity;


/**
 * @Author 刘志伟
 * @create 2022/9/26 11:34
 */

/**
 * 思考，这层是不是可以将接口开放出去，然后IUserService & UserService分开呢？
 * 只做编排（比如redis相关）
 */
@Service("orderService")
public class OrderService {

    @Resource(name = "orderRepository")
    private IOrderRepository iOrderRepository;

    public void createOrder(OrderDTO orderDTO){

        iOrderRepository.save(orderDTO2OrderEntity(orderDTO));
    }
    public OrderDTO getOrderById(String id) {

        OrderEntity entity = iOrderRepository.getOrderById(id);
        return entity2OrderDTO(entity);
    }
}
